package org.xc.consumer.contorller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xc.consumer.service.ProducerService;

/**
 * @author Administrator
 * @date 2018/8/8
 */
@RestController
public class TestCtrl {

    @Value("${server.port}")
    private String port;

    @Autowired
    ProducerService producerService;

    @RequestMapping("/test")
    public String test() {
        return "test-consumer;port:" + port;
    }

    @HystrixCommand(fallbackMethod = "testProducerErr")
    @RequestMapping("/testProducer")
    public String testProducer() {
        return producerService.testProducer();
    }
    public String testProducerErr() {
        return "服务超时";
    }

}
